/*
 * @Author: shimmer
 * @Date: 2022-05-07 14:21:36
 * @LastEditors: shimmer
 * @LastEditTime: 2022-05-09 15:53:35
 * @Description:
 *
 */
import React, { FC } from "react";
import { shallowEqual } from "react-redux";
import { useAppDispatch, useAppSelector } from "../redux/hook";
import { add, minus, getAsyncInfo } from "../redux/slice";

export const APage: FC<any> = () => {
  console.log("A渲染了");

  const { count } = useAppSelector((state: any) => ({ ...state.state }), shallowEqual);
  const dispatch = useAppDispatch();

  return (
    <div>
      <h1>我是Apage</h1>
      <h2>我是count:{count}</h2>
      <button
        onClick={() => {
          dispatch(add());
        }}
      >
        加1
      </button>
      <button
        onClick={() => {
          dispatch(minus());
        }}
      >
        减1
      </button>
      <button
        onClick={() => {
          dispatch(getAsyncInfo());
        }}
      >
        异步加10
      </button>
    </div>
  );
};
